package main

import (
	"flag"
	"fmt"
	"google.golang.org/grpc"
	"log"
	"net"
	"user_service/basic/config"
	"user_service/basic/nacos"
	__ "user_service/basic/proto"
	"user_service/handler/service"
	"user_service/inits"
)

var (
	port = flag.Int("port", 8888, "The server port")
)

// server is used to implement helloworld.GreeterServer.

func main() {
	config.ViperInit()
	nacos.NacosConfig()
	inits.MysqlInit()

	Weights(sum)

	flag.Parse()
	lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	__.RegisterUserServer(s, &service.Server{})
	log.Printf("server listening at %v", lis.Addr())
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}

var sum float32

func Weights(weight float32) float32 {
	weight += sum
	return sum
}
